package net.cyndeline.entitySystem.event

import net.cyndeline.entitySystem.Component
import net.cyndeline.entitySystem.Event
import net.cyndeline.events.ModifyError

class AddComponent extends AddComponentEvent with ModifyError {
  private var comps = List[Component]()
  
  override def components = comps
  
  override def components_=(componentList: List[Component]) {
    modify(componentList.toString, this)
    comps = componentList
  }
  
  override def components_=(component: Component) {
    val list = (component :: Nil)
    components = list
  }
  
  override def copy = {
    val copy = new AddComponent()
    val componentCopies = comps.map(_.copy)
    copy.components = componentCopies
    copy
  }
}

trait AddComponentEvent extends Event {
  def components: List[Component]
  def components_=(comps: List[Component])
  def components_=(comps: Component)
}